package com.yeyks.rabbitmq.send;

import com.yeyks.rabbitmq.queue.RabbitMqQueue;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author fuchangshuai
 * @date 2019/4/10 2:43 PM
 */
@Component
public class OrderQueueMsg {

    private final String ORDER_TO_B_EXCHANGE = "order.to.b.exchange";
    private final String ORDER_TO_B_KEY = "order.to.b.key";


    @Autowired
    private AmqpTemplate template;

    /**
     * 发送推送消息
     *
     * @param message
     */
    public void send(String message) {
        template.convertAndSend(RabbitMqQueue.ORDER_WEBSOCKET_EXCHANGE,
                RabbitMqQueue.ORDER_WEBSOCKET_KEY, message);
    }

    /**
     * C端下单成功下发一下消息供B端使用
     *
     * @param message
     */
    public void sendToB(Object message) {
        template.convertAndSend(ORDER_TO_B_EXCHANGE, ORDER_TO_B_KEY, message);
    }
}
